Automated programmable battery balancing system and method of use

ABSTRACT

The present disclosure provides a programmable controller for monitoring battery performance and usage at a remote pump jack location. The disclosure provides an energy efficient controller and display system which allows the operator to quickly and accurately test batteries in an installation. It uses programmable logic to switch between system modes and decide which battery supplies power to the output. Further it will sense any high voltages at and disable the input from the faulty source. Further, the programmable logic is designed such that the mode selection process is automatic when the system is in operation. The purpose is to elongate battery and connected equipment life by preventing battery failure. The present disclosure also provides an easy and economical method of communicating potential battery failure and status to an operator via cell phone communication.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. patent application Ser. No.15/185,874 filed on Jun. 17, 2016, now U.S. Pat. No. 10,263,455, whichis hereby incorporated by reference herein.

FIELD OF THE DISCLOSURE

The present invention relates generally to the control units forchemical pumps at oil well pump jacks and more particularly to a devicewhich enables adjustment of power supplies from two or more batteriesand to monitor the conditions of each battery at each well site forstatus information and transmission of such information through aneconomical text message format to an operator.

BACKGROUND OF THE DISCLOSURE

In the production phase of an oil well, it is usually necessary toartificially lift the crude oil from its natural level in the wellboreto the wellhead. The two most common lift methods are to use either asurface pumping unit or a subsurface rotary pump. A familiar sight inthe oil fields around the world is the conventional beam pumping unit(pump jack). This method of bringing oil to the surface accounts forbetween 70% to 80% of the artificial lifting of oil. The pumping unitmay be powered by either an electric motor or an internal combustionengine. In either case it is usually necessary to couple the motor andpump through a speed reducer. A reduction of 30 to 1 is typically neededto operate the pump at 20 strokes per minute (spm). The rotation of theprime mover is converted into an up-and-down motion of the beam andhorse head through a pitman/crank assembly. The oscillating horse headof the pumping unit raises and lowers a sucker rod and reciprocates thesucker rod pump in the wellbore. This action lifts the oil on theupstroke to the wellhead.

During production it is often necessary to inject a treatment chemicalinto the annular space between the well casing and tubing. These mightinclude demulsifiers, corrosion inhibitors, scale inhibitors, paraffininhibitors, etc. Demulsifiers are chemicals used to dehydrate crude oilcontaining emulsified water. In many cases this water-in-oil emulsion isvery stable. Without the use of a demulsifier, the water would notseparate from the crude oil. The rapid separation of the water from theoil phase may be necessary at the well site because of limited storagecapacity. The combined total of water remaining in the crude oil must bebelow 1% in most cases. Excess water can cause serious corrosionproblems in pipelines and storage tanks. In addition, water in arefinery stream can interfere with the distillation process and damagethe refinery equipment.

In wells which use a production pumping unit, a small chemical pump maybe used to inject the treatment chemical into the wellhead. Severaltypes of chemical pumps are known in the art. For example, apneumatically powered system creates motor force by utilizing compressedair or gas to power a motor. The motor applies forces to a plunger ordiaphragm which in turn inject chemical into the well at a measuredrate. Another example is electrically powered systems. These systemscreate motor force by utilizing municipal electricity to power anelectrical motor. The motor applies force to a plunger or diaphragmwhich in turn injects the chemical. A variant of the electricallypowered system is a solar powered system which utilizes solar cells tocreate electricity. The electrical current is stored in a battery bankwhich in turn powers a DC electric motor. Sealed gel or a matted glassbatteries are required due to deep cycle requirements of theenvironment. Furthermore, these systems must be designed to operatewithout sunlight for extended periods of time up to thirty days inlocations such as Canada, Northern Russia or the Artic.

In solar powered systems extended delays without sunlight due to cloudyweather or location can create a problem for maintaining battery voltageand therefore proper chemical injection rate.

It is therefore extremely important to provide reliable battery servicefor chemical injection pumps for pump jacks. However, as with othermechanical systems of the pump jack, routine maintenance is required toassure battery performance. The routine maintenance is difficult toprovide because the battery usage varies widely from installation toinstallation. In the prior art, to assure battery performance anoperator is required to periodically travel to the installation and testthe batteries to prevent failure. Repeated travel to the installationraises costs and reduces profit. Similarly, neglected batteries caneasily cause injection failure with concomitant losses in production orefficiency.

SUMMARY OF THE DISCLOSURE

The present disclosure provides a programmable controller for monitoringbattery performance and usage at a remote pump jack location. Thedisclosure provides an energy efficient controller and display systemwhich allows the operator to quickly and accurately test batteries in aninstallation. It uses programmable logic to switch between system modesand decide which battery supplies power to the output. Further it willsense any high voltages at and disable the input from the faulty source.Further, the programmable logic is designed such that the mode selectionprocess is automatic when the system is in operation. The purpose is toelongate battery and connected equipment life by preventing batteryfailure. The present disclosure also provides an easy and economicalmethod of communicating potential battery failure and status to anoperator via cell phone communication.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a schematic of a dedicated control system for a chemical pumpin place at a pump station.

FIG. 2 is a schematic view of the components of a preferred embodimentof the present disclosure.

FIG. 3 is a schematic of the microcontroller circuit of a preferredembodiment of the present disclosure.

FIGS. 3A-3D is a schematic of the microcontroller circuit of a preferredembodiment of the present disclosure.

FIG. 4 is a schematic of the sensing control circuit of a preferredembodiment of the present disclosure.

FIGS. 4A-4C is a schematic of the sensing control circuit of a preferredembodiment of the present disclosure.

FIG. 5 is a schematic diagram of a communications board of a preferredembodiment of the present disclosure.

FIG. 6A is a flowchart of the system functions of a preferredembodiment.

FIG. 6B is a flowchart of a status interrupt request of a preferredembodiment.

FIG. 6C is a flowchart of a system communication interrupt request of apreferred embodiment.

FIG. 7A is a preferred embodiment of a look up table of a preferredembodiment.

FIG. 7B is a preferred embodiment of a look up table of a preferredembodiment.

FIGS. 8A-8V are a preferred embodiment of a software program stored inmemory of the microcontroller circuit.

FIGS. 9A-9U are preferred embodiments of .cpp programs and .h libraryfiles of a preferred embodiment.

DETAILED DESCRIPTION

Referring then to FIG. 1 a preferred embodiment of system 100 will bedescribed. Solar panel 102 and 104 are connected to charger regulators106 and 108 respectively. The solar panels in a preferred embodiment are80 watt solar panels which generate less than 20 volts a piece. Chargerregulators 106 and 108 are capable of transferring approximately 14volts to each battery and serve to regulate the output from the solarpanels. Battery 110 and battery 112 are connected to charger regulators106 and 108, respectively. In a preferred embodiment the batteries aresealed gel deep cycle storage batteries suitable for solar applications.

Batteries 110 and 112 are connected to dedicated machine 114 which willbe further described. Dedicated machine 114 directly powers chemicalpump 118. Chemical pump 118 distributes chemicals from tank 116 to pumpjack 120, at the well head.

Referring then to FIG. 2 dedicated machine 114 further includesmicrocontroller board 202 connected to or integrated with a sensingcontrol board 204. The sensing control board is connected to relay 206and relay 208. Relay 206 is connected to battery 110. Similarly, relay208 is connected to battery 112. The relays are connected to thechemical pump 118 and, when activated, distribute electrical power fromthe batteries to the chemical pump. The microcontroller board is alsoconnected to a communications board 210. The communications board thatis periodically connected to cell phone 212 through a cellular network(not shown).

Referring then to FIGS. 3A-3D, the schematic of microcontroller board202 will be described. The microcontroller board includes two separateprocessors, processor 302 and processor 304. Processor 304 is used toreceive and store programming instructions from USB port 305 as will befurther described. The programming instructions are passed to processor302 through jumpers between Port B of processor 304 and Port B ofprocessor 302, where they are stored in Flash memory. Processor 302receives analog input related to battery voltages through Port C atinputs AD0 through AD5 located at pins 23 through 28. Processor 302communicates output voltages through Port D labeled IO0 through IO7located at pins 2, 3, 4, 5, 6, 11, 12, and 13.

In the preferred embodiment, processor 302 is Atmega328p-pumicrocontroller available from Atmel Corporation, San Jose, Calif.Processor 304 is the Atmega16u2-um(r) microcontroller also availablefrom Atmel Corporation. In another preferred embodiment, both processorsare available in an integrated package, Arduino 3 available fromAdafruit Industries of New York, N.Y. (or other supplier).

Referring then to FIGS. 4A-4C, the sensing control board will be furtherdescribed. Sensing control board 204 is connected to the microcontrollerboard via connectors J1 and J2. Connector J1 provides VCC, RESET, GROUNDand VIN signals. Connector J2 provides access to the analog Port Dthrough pins 1 through 6 labeled AD0 through AD5. VIN voltage signalsupplies the microcontroller and sensor board with power.

Input/output is provided through connectors IOL and IOH labeled IO0through IO7 and IO8 through IO13, respectively. AREF is the analogreference pin for the Analog-to-Digital converter (ADC) of themicrocontroller.

Connector J4 is connected to relay 206 at pin 1 and relay 208 at pin 4.Pin 3 of the connector is attached to ground. Pin 2 of the connector isattached to control voltage VIN2 and is used to power the relays ON andOFF. Pin 1 is also connected to the collector of Q5 and the collector ofQ6. The emitter of Q5 and Q6 both are tied together and then to ground.The collector of Q5 and Q6 are also tied to the control voltage VIN2through voltage control resistors R13 and R17, respectively. The base ofQ5 is tied to IO04 through voltage control resistor R12. The base of Q6is tied to IO05 through voltage control resistor R18. VIN2 voltagesignal supplies the relays and relay control circuits with powerdirectly from the batteries, thereby isolating the relay circuits fromthe microprocessor control board power circuit.

When IO4 goes high, Q5 is activated bringing pin 4 of J4 low. When pinJ4 goes low, relay 1 is activated and battery 110 is connected to theload. When I04 goes low, Q4 is deactivated bringing pin 4 of J4 tocontrol voltage VIN2. When pin 4 is at control voltage VIN2, relay 1 isdeactivated thereby disconnecting the battery from the load.

Similarly, when IO05 is high, Q6 is activated, bringing pin 1 to ground.When pin 1 is at ground, relay 2 is activated, thereby connectingbattery 112 to the load. When IO5 is low, Q6 is deactivated bringing pin1 of J4 to control voltage VIN2. When pin 1 is at VIN2, relay 2 isdeactivated and battery 112 is disconnected from the load.

Connector 3 is attached to the battery and to ground. Pin 1 of connector3 is connected to the positive side of battery 112. Pin 2 of connector 3is attached to ground. Pin 3 of connector 3 is connected to ground. Pin4 of J3 is connected to the positive terminal battery 110. Both negativeterminals of battery 112 and battery 110 are connected to ground.

Pin 1 of J3 is also connected through diode D2 to one terminal of singlepole single throw switch U2. Pin 1 of J3 is also connected to theemitter of transistor Q8. The collector of transistor Q8 is connected tothe voltage divider made up of R15 and R11. At the midpoint of thevoltage divider comprised of R15 and R11, a connection is made to analoginput AD1. AD1 is tied to a stabilizing network comprised of R11 and C2through diode D7 to supply voltage VCC. The base of Q8 is also tiedthrough voltage control resistor R6 to the collector of Q2. The emitterof Q2 is tied to ground. The collector of Q2 is tied through voltagecontrol resistor R2 to control voltage VIN2.

In a similar way, pin 4 of J3 is also connected through diode D1 to oneterminal of single pole single throw switch U2. Pin 4 is also tied tothe emitter side of Q7. The base of Q7 is connected through voltagecontrol resistor R5 to the collector Q1. The emitter of Q1 is tied toground. The collector of Q7 is connected to one side of the voltagedivider comprised of resistors R14 and R10. At the midpoint of thevoltage divider a connection is made to analog input AD0. AD0 isconnected through a stabilizing network comprised of resistor R10, diodeD6, and capacitor C1 through diode D5 to supply voltage VCC.

The second terminal of single pole single throw switch U2 is connectedthrough voltage control resistor R1 to the base of Q2. In the same way,the second terminal of single pole single throw switch U2 is connectedthrough voltage control resistor R2 to the base of Q2. The secondterminal is also connected to the control voltage VIN2. The secondterminal is also connected to the collectors of Q3 and Q4. The emitterof Q4 is tied through voltage control resistor R9 to power voltage VIN.The emitter of Q4 is tied through voltage control resistor R8 also tocontrol voltage Vin. The bases of Q3 and Q4 are tied to stabilizingdiodes D3 and D4 and stabilizing Zener diode D9 to ground.

In a similar way, the collectors of Q3 and Q4 are connected tostabilizing network comprised of R16, R19, D1, D11, and C3. R16 and R19form a voltage divider. At the midpoint of this voltage divider, asignal is drawn and connected to IO6. IO6 and IO7 are the inputs for theanalog comparator module of the processor. IO7 is connected to the 3.3Vreference voltage pin. IO6 is R19/(R16+R19) of the battery voltage andunder normal operation will be lower than the 3.3V IO7 referencevoltage. In case of charge controller failure, the IO6 voltage will behigher than IO6 triggering the analog reference interrupt on theprocessor.

Connector J5 is joined at pin 1 to supply voltage VCC. At pin 3, theconnector is attached to GROUND. At pin 2, the connector is joined tocolor RGBLED U1. The control signals for red are connected throughresistor R20 to IO8, for blue through resistor 21 to IO10, and for greenthrough R22 to IO9. This jumper allows the choice of the color RGBLED tobe common cathode or common anode variety.

Push-button spring loaded switch U3 is connected at one terminal toground and at the other to IO2. The switch is used to initiate a signalinterrupt which activates the function of the color RGBLED U1.

In operation, switch U2 is used as an “ON-OFF” switch which activatessensing control board 204, microcontroller board 202 and communicationsboard 210. When the switch is in the “OFF” position, terminal 1 isconnected to the high side of both battery 110 and battery 112 throughjumper J3. Isolation diodes D1 and D2 prevent a short circuit. Thecollector of both Q1 and Q2 are both effectively low due to theisolation effect of diodes of D3 and D4. As a result, the base of Q7 andQ8 are drawn high through voltage control resistors R3 and R4. In thisstate, both Q7 and Q8 do not conduct and the outputs AD0 and AD1 areeffectively low or float. In the same way, IO6 is drawn low through R19to ground.

When U2 is closed, current moves through isolation diodes D1 and D2through resistors R1 and R2 to the bases of Q1 and Q2. Both transistorsare energized thereby setting the bases of Q7 and Q8 to ground. When setto ground, Q7 and Q8 conduct and voltages AD0 and AD1 reflect thevoltages of battery 110 and battery 112, respectively. In a similar way,the voltage divider comprised of R16 and R19 is energized and IO6 drawnhigh. When U2 is closed, the positive sides of battery 112 and battery110 also energize the bases of Q3 and Q4 through voltage controlresistor R7. Current flow from the collectors of Q3 and Q4 to VINthereby energizes the system.

Referring then to FIG. 5, the communication board will be described.Communication board 210 includes a power management unit 502 connectedto a radio frequency controller 504. The radio frequency controller isconnected to bus 506. The radio frequency controller is also connectedto GSM module 508 for global system and mobile communications. Radiofrequency controller 504 is also connected to a Bluetooth module 510.Power management unit 502 is directly connected to and powers analogbaseband module 512 and digital baseband module 514. Both analogbaseband module 512 and digital baseband module 514 are connected to bus506.

The power management module is also connected to power supply 516. Thepower management module is also connected to real time communicationsunit 518 which enables exchange of multimedia and audio content in realtime. GPS receiver 520 is also connected to bus 506. Analog interface522 includes audio interface 524 and Analog to Digital (“SIM”) converter526.

Digital interface 528 includes an interface for a subscriber identitymodule 530, a universal asynchronous receiver/transmitter 532, a keypad534, an ion window manager 536, inter-integrated circuit (I2C computerbus) 538, a pulse code modulation decoder for representing sampledanalog signals 540, and a universal serial bus 542.

In a preferred embodiment, the communication board is the Adafruit 808GSM+GPS Shield based on the SIM800/SIM900 module. The 808 GSM+GPS Shieldboard is available from Adafruit Industries.

Referring then to FIG. 6A the functions 600 of a preferred embodimentwill be described. At step 602, the system is initialized by activatingthe program code which is resident in flash memory. The code setsvariables and initializes the processors as will be further described.Custom programming of the system can be accomplished at this step bychanging certain variables which will change system operation. Oneexample is changing the battery voltage level definitions as shown inrelation to FIG. 8B, as will be further described. Another example ischanging the system modes as shown in FIGS. 8N-80, as will be furtherdescribed. If changes are made, the code is downloaded to the processorat this step. In this embodiment, the code is written in C. Of course,other languages will suffice.

At step 603, the microprocessor continuously monitors IO6 for an overvoltage condition. If at any time, an over voltage condition isdetected, then an over voltage detection interrupt is indicated and thesystem performs steps 604-610 and disconnects the appropriate batterypath (battery 1 or 2) with the overvoltage condition. Under normaloperation conditions, the system executes step 604.

At step 604, the microprocessor reads the battery levels indicated byAD0 and AD1. A reference table similar to Table 1, is consulted whichindexes battery voltages for battery 110 and battery 112 against abattery charge level or status. Table 1 shows a preferred embodiment ofvalues for the voltage thresholds to determine battery charge andstatus.

TABLE 1 Voltage Range (V) Battery Charge/Status Low High VHIGH 16.0020.00 VCHARGING 12.75 15.99 V100 12.50 12.74 V75 12.16 12.49 V50 11.8612.15 V25 11.62 11.85 V0 11.5 11.61 VFAIL 2.00 11.49 VGND 0.00 1.99

The thresholds can be changed by the operator and programmed into thesystem based on the application.

Table 2 shows another preferred embodiment of values for voltagethresholds to determine battery charge and status.

TABLE 2 Voltage Range (V) Battery Charge/Status Low High VHIGH 16.0020.00 VCHARGING 12.75 15.99 V100 12.50 12.74 V75 12.25 12.49 V50 12.0012.24 V25 11.75 11.99 V0 11.5 11.74 VFAIL 2.00 11.49 VGND 0.00 1.99

At step 606, the system updates the system mode by indexing the batteryvoltage status for all batteries in the system, against anotherreference table (similar to FIG. 7A or FIG. 7B) to determine a system“mode”, as will be further described. The system then moves to step 608.

At step 608, the microprocessor sends appropriate signals to IO4 andIO5, thereby setting relays 206 and 208 to connect either battery 110,battery 112, or both to the load. At step 609, the system loads the modeof the system into the communications board and instructs it to send themode to the operator in a SMS format, if system mode has changed or theperiodic communication time has been reached. Of course, other formatsare possible in other embodiments. The system then moves to step 610. Atstep 610, the microprocessor delays all activity for a predeterminedperiod of time. After the predetermined period of time, the systemreturns to step 604. The system loops through the flowchart in FIG. 6Aperiodically and continuously unless stimulated by an overvoltage orcommunication interrupt.

Referring to FIG. 6B a status request interrupt, 650 is described. Atstep 651, the microprocessor waits for an interrupt. At step 652, themicroprocessor receives an interrupt request to display status,triggered by spring-loaded push-button switch U3 pressed by theoperator. The system then moves to step 654. At step 654, the systemgenerates a status code as shown in Table 3. At step 656, themicroprocessor returns from the routine.

TABLE 3 BATTERY LEVELS ← BAT 1 BAT 2 → 1 FLASH 2 FLASHES UNKNOWN BLANKREG FAIL RED CHARGING WHITE HIGH GREEN MEDIUM YELLOW LOW RED BAT FAILCYAN NO BAT BLUE

In a preferred embodiment, the system indicates the status of battery110 by a single white flash followed by a single color LED flashindicating charge level or status and battery 112 by two white flashesfollowed by a single color LED flash indicating charge level or status.For each battery, if the charge level is low, a red signal is sent. Ifthe battery is charging, a white signal is sent. If the battery chargelevel is high, a green signal is sent. If the battery charge conditionis medium, a yellow signal is sent. If the battery charge regulator hasfailed indicating abnormally high voltage, a red signal is sent. If abattery has failed, a cyan signal is sent, and if no battery is present,a blue signal is sent.

Referring then to FIG. 6C a flowchart 675 for a preferred embodiment ofsystem communications will be described. The smart switch can beequipped with a cellular communication module daughterboard for remotecommunication and control capability. Communication with the remoteoperator can be via SMS/text messages that include system statusmessages and alerts. The cellular communication module will be usedeither in continuous mode or hibernation mode to communicate with theremote operator. In the continuous mode it will allow incomingcommunication and connectivity to the switch, allowing the remoteoperator to monitor status and control the switch via a remote requestor user interface. In the hibernation mode, the cellular communicationmodule will be powered up either (a) periodically (period set by user)or (b) upon critical system mode change (such as low battery or batteryfailure), to send system status messages and alerts to the remoteoperator. The hibernation mode will be normally used due to powerconsumption considerations. In continuous communications mode, thesystem monitors for an interrupt signal from the communication board. Ifan interrupt is detected then a function is performed to initiate SMScommunication with the operator as will be further described.

At step 677, the system waits for a system communication interrupt if itis in continuous communications mode only. Under the default hibernationmode the system goes periodically to step 679 directly, and checkswhether the conditions to send a message to the operator have been met.The conditions that need to be met are either (a) system mode haschanged or (b) periodic time for communication has been reached or (c)remote request text has been buffered while the system was offline. Atstep 681, if either step 677 or step 679 indicate that a message needsto be communicated to the remote operator, the system creates the statusmessage to be sent via SMS text. At step 683, the system retrieves thephone number of the operator to which the text message is to be sent.

At step 685, the system activates the communications board which hasbeen asleep, if the system communication board has been in hibernationmode. At step 687, the system loads the system status into a SMS packet.At step 689, the communications board sends the text message includingthe packet showing the system status details including battery voltages.

At step 691, the system returns from the handle communications routine.

Referring then to FIG. 7A, the system mode table will be described. Thesystem mode table comprises six codes which are generated depending on amatrix of battery voltages. Table 4, below describes the system modedefinitions.

TABLE 4 System Mode Definitions E0 - only battery 1 supplying power E1 -only battery 2 supplying power E2 - no power - no battery voltages M1 -normal mode switching periodically M2 - switching based on batterylevels M3 - both batteries supplying power

Table 3 shows that in mode E0 battery 110 alone is supplying power tothe system. In mode E1 battery 112 alone is supplying power to thesystem. In mode E2 both batteries are not in service and no power issupplied to the system. In mode M1, considered “normal mode” the systemtoggles between battery 110 supplying power and battery 112 supplyingpower after the sleep cycle. In mode M2 the system switches betweenbattery 110 and battery 112 so that the battery with the highest voltagelevel is connected to the system. In mode M3 both battery 110 andbattery 112 are connected to the system and supply power to it.

As indicated earlier, voltage threshold settings (boundary voltagelevels to determine battery charge or status) can vary based on operatoror customer input for specific applications. Battery status is set toone of the charge or status modes indicated in Table 1. A system mode isset based on the mapping of the battery modes into a system mode table.For each set of battery modes a system mode can be and is assigned. Twoembodiments of such assignment tables are shown in FIG. 7A and FIG. 7B,respectively. It can be seen from FIG. 7A that the system mode is set toE0 when battery 110 charge/status is V0, V25, V50, V75, V100 orVCHARGING AND battery 112 charge/status is VGND, VFAIL or VHIGH. Mode E1is set where battery 110 charge/status is VGND, VFAIL or VHIGH andbattery 112 charge/status is V0, V25, V50, V75, V100 or VCHARGING. ModeE2 is set when battery 110 charge/status is VGND, VFAIL or VHIGH ANDbattery 112 charge/status is also VGND, VFAIL or VHIGH.

Referring further to FIG. 7A, system mode is set to M1 when battery 110charge/status is V0, V25, V50, V75, V100 or VCHARGING and battery 112charge/status is V75, V100 or VCHARGING. System mode is also set to M1when battery 110 charge/status is V75, V100 or VCHARGING and battery 112charge/status is V0, V25, V50, V75, V100 or VCHARGING. The system modeM2 is set where battery 110 charge/status is V0, V25, or V50 AND battery112 charge/status is V0, V25, or V50.

Referring to FIG. 7B, the system mode is set to E0 when battery 110charge/status is V0, V25, V50, V75, V100 or VCHARGING and battery 112charge/status is VGND, VFAIL or VHIGH. Mode E1 is set where battery 110charge/status is VGND, VFAIL or VHIGH AND battery 112 charge/status isV0, V25, V50, V75, V100 or VCHARGING. Mode E2 is set when battery 110charge/status is VGND, VFAIL or VHIGH AND battery 112 charge/status isalso VGND, VFAIL or VHIGH.

Referring further to FIG. 7B, system mode is set to M1 when battery 110charge/status is V0, V25, V50, V75, V100 or VCHARGING and battery 112charge/status is V75, V100 or VCHARGING. System mode is also set to M1when battery 110 charge/status is V75, V100 or VCHARGING and battery 112charge/status is V0, V25, V50, V75, V100 or VCHARGING. The system modeM2 is set where battery 110 charge/status is V50 AND battery 112charge/status is V0, V25, or V50. The system mode M2 is also set wherebattery 110 charge/status is V0, V25, or V50 AND battery 112charge/status is V50.System mode M3 is set when battery 110charge/status is V0 or V25 AND battery 112 charge/status is V0 or V25.

All voltages are sensed within a tolerance of about 0.2 volts without aprecision voltage reference input and should be anticipated to be aboutthe voltage specified. A precision voltage reference with 0.01% accuracycan be alternatively used to enhance accuracy.

Referring then to FIGS. 8A-8V, a preferred example of programming code,written in C, for controlling the microcontroller and the system isdescribed.

Code section 802 loads libraries that contain functions to be executedby the processor. The processor libraries are available athttps://github.com/leomil72/analogComp andhttps://github.com/n0m1/Sleep_n0m1. Code section 802 also loadslibraries that contain functions to be executed by the communicationsboard. The Adafruit libraries are available athttps://github.com/adafruit,Adafruit_FONA.

Code section 804 defines variables and parameter definitions to be usedby the program.

Code section 806 defines the setup function which runs during systeminitialization. This section invokes several libraries of themicrocontroller to test system functions. The libraries are located athttps://www.arduino.cc/en/Reference/Libraries.

During code section 806, the data rate is set for the communicationsboard and the SIM card IEMI number is located and retrieved. During codesection 806, the sleep time variable is set and the relays are tested.Initial battery levels are set. Scaling factors for the analog input areset. Voltage divider ratios are set. Initial relay variables are set.Initial mode of the system is set. The system then enables interrupts,tests the battery levels, and updates the battery mode and system mode.The system then defines the colors of the LED to be displayed duringvarious system status interrupt responses.

The fona.getIMEI function retrieves the SIM card number from thecommunication board. The serial.begin function sets the data rate inbits per second per a serial data transmission. The interrupt for thedigital pin is attached to a specific interrupt service routine. Thepinmode function configures the specified pins of the microprocessor tobehave either as an input or an output. Interrupts are enabled aftersystem setup is complete. The delay function suspends the program for100 clock cycles. The digital color LED is cycled through the specifiedstatus colors for a specified number of clock cycles indicating theconclusion of the startup sequence. The analogcomparator function isenabled with AIN0 and AIN1 as inputs. The analogcomparator.enableinterrupt function is attached and to enable execution when a differenceoccurs between the voltages at pins AIN0 and AIN1.

In code section 808, the system enters a repetitive loop to monitorcommunications, measure the battery levels, update the system mode, andset the relays on a continuous basis. The program then enters powersavings mode while monitoring for any interrupts that may occur.

The digitalread function reads the value from a specified microprocessorpin, either low or high to determine if the system is in DEBUG mode. Thehandle communications function is also called to send any text messagesif necessary conditions have been met. The sleep.ADCmode function setsthe microprocessor into an idle sleep mode thereby saving power. Thefunction stops the MCU but leaves the peripherals and timer running. Thesleep.sleepDelay function sets the number of clock cycles during whichthe power setting mode is active.

At code section 810, a function is provided to measure the battery 110and battery 112 voltage levels. In this section, the microprocessorreads AO and A1, averaged over four readings to reduce noise and appliesa scale factor before exiting.

The analogread function obtains the analog voltage value at thespecified pin.

At code section 812, a function is provided which compares the batterylevels to determine battery charge/status.

At code section 814, the system mode is updated to implement the tablesshowed in either FIG. 7A or FIG. 7B.

At code section 816, the program sets the relays according to the systemmode provided in the tables. The digitalwrite function sets the value ata specified microprocessor pin to either high or low. In mode M1 thesystem toggles the battery supplying power to the pump controller afterthe sleep delay. If there are two batteries and one battery is currentlysupplying power, the system will switch to the other battery allowingthe first battery to be charged for the ensuing delay period. Theprocess is repeated as long as the system is in mode M1.

At code section 818, the LED is set to indicate the battery status forbatteries 110 and 112 according to Table 1 and Table 2.

At code section 820, the processor is instructed to set the red, green,and blue LED pins to implement the mode defined in code section 818.

At code section 822, a function is provided which sets the flagindicating that the operator has requested status indicator displayusing the interrupt mechanism.

At code section 824, a function is provided which services the analoginterrupt which occurs when one of the two batteries is in over voltagecondition.

At code section 826, the handlecommunications function is defined. Thehandlecommunications function loads a value for the battery levels ofbattery 110 and battery 112 into the reply buffer variable. The functionalso defines two cases, COMMCONTINUOUS and COMMHIBERNATE. During aCOMMCONTINOUS case the function checks to see if a SMS message has beenreceived, and if so, it responds. The function also monitors the modesof the system, and if a system error occurs, sends a SMS message to theoperator. In the default case COMMHIBERNATE, the function powers up thecommunications board only if a problem arises. Once powered up, theboard is instructed to send a SMS message located in the reply buffervariable. The function then powers down the communications board to savepower.

The fona.powerstatus function returns true if the communications boardis powered up and functioning. The fona.powerup function turns on thecommunication board. The fona.available returns true if data is presentin the communications board incoming memory. The fona.read functionreturns the data in the communication board memory. Thefona.getSMSSender function which returns a designated number ofcharacters from the communications board which define the SMS senderaddress and phone number. The fona.sendSMS sends the content of avariable to a designated phone number in SMS format. The fona.deleteSMSfunction clears SMS messages from incoming slots. Thefona.powerdownfunction turns off the communications board.

Referring then to FIGS. 9A-9G, the program listing of the analog copanalogComp.cpp file is shown. The functions are described in the remarksin the Figure.

Referring then to FIGS. 9H-9J, the program list of the analogComp_h andshows a library file referenced by the analog cob function. Thefunctions are described in the remarks in the Figure.

Referring then to FIGS. 9K-9Q, the Sleep_n0m1.cpp file is shown. Thefunctions are described in the remarks in the Figure.

Referring then to FIGS. 9R-9U, the Sleep_n0m1.h libraries are defined.The functions are described in the remarks in the Figure.

It will be appreciated by those skilled in the art that the describedembodiments disclose significantly more than an abstract idea includingtechnical advancements in the field of data processing and atransformation of data which is directly related to real world objectsand situations in that the disclosed embodiments enable a computer tooperate more efficiently. For example, the disclosed embodimentstransform positions, orientations, and movements of durable plant tagsas well as transforming one or more servers and hand held devices fromone state to another state.

It will be appreciated by those skilled in the art that modificationscan be made to the embodiments disclosed and remain within the inventiveconcept. Therefore, this invention is not limited to the specificembodiments disclosed, but is intended to cover changes within the scopeand spirit of the claims.

1. A system for balancing power supplied to a load by a first batterythrough a first switch, and a second battery through a second switch,comprising: a microcontroller; a memory connected to themicrocontroller; a first sensor connected to the microcontroller and thefirst battery; the first battery connected to the first switch; a secondsensor connected to the microcontroller and the second battery; thesecond battery connected to the second switch; the microcontrollerconfigured to: measure a first voltage level of the first battery withthe first sensor; measure a second voltage level of the second batterywith the second sensor; compare the first voltage level and the secondvoltage level to a voltage table to determine a set of system modes; setthe first switch according to the system mode; set the second switchaccording to the system mode; whereby one of the group of the firstbattery, the second battery and a combination of the first battery andthe second battery is connected to the load; and, enter a sleep statefor a predetermined period of time where no comparison of the firstvoltage level and the second voltage level are made.
 2. The system ofclaim 1 wherein the microcontroller is further configured to: cancel thesleep state if an overvolt condition is detected at one or more of thefirst battery and the second battery.
 3. The system of claim 1 whereinthe set of system modes further comprises: a first system mode wherebythe first switch and the second switch are set to alternately supplypower from the first battery and the second battery to the load; and, asecond system mode whereby the first switch and the second switch areset to supply power to the load based on the first voltage level and thesecond voltage level.
 4. The system of claim 3 wherein the set of systemmodes further comprises a third system mode whereby the first switch andthe second switch are set to supply power from both the first batteryand the second battery to the load.
 5. The system of claim 1 wherein thevoltage table further comprises: a first set of voltage ranges relatedto the first battery; a second set of voltage ranges related to thesecond battery; and, a set of system modes corresponding to at least onevoltage range from the first set of voltage ranges and at least onevoltage range from the second set of voltage ranges.
 6. The system ofclaim 5 wherein the first set of voltage ranges further comprises afirst set of thresholds and the second set of voltage ranges furthercomprises a second set of thresholds.
 7. The system of claim 5 whereinthe first set of voltage ranges further comprises: about 0.0 to about1.99 volts; about 2.0 to about 11.49 volts; about 11.5 to about 11.61volts; about 11.62 to about 11.85 volts; about 11.86 to about 12.15volts; about 12.16 to about 12.49 volts; about 12.50 to about 12.74volts; about 12.75 to about 15.99 volts; and, greater than about 16volts. And the second set of voltage ranges further comprises: about 0.0to about 1.99 volts; about 2.0 to about 11.49 volts; about 11.5 to about11.61 volts; about 11.62 to about 11.85 volts; about 11.86 to about12.15 volts; about 12.16 to about 12.49 volts; about 12.50 to about12.74 volts; about 12.75 to about 15.99 volts; and, greater than about16 volts.
 8. The system of claim 4 wherein the set of system modesfurther comprises: a first system mode wherein one condition is met ofthe group of: the first voltage level is between about 11.5 and about 16volts and the second voltage level is between about 12.16 and about 16volts; and, the first voltage level is between about 12.16 and about 16volts and the second voltage level is between about 11.5 and about 12.16volts; a second system mode wherein the first voltage level is betweenabout 11.5 and about 12.16 volts and the second voltage level is betweenabout 11.5 and about 12.16 volts.
 9. The system of claim 8 wherein theprocessor is further configured to: set the first switch and the secondswitch to alternate a supply of power to the load from the first batteryand the second battery in the first system mode; and, set the firstswitch and the second switch to supply power to the load from either thefirst battery or the second battery dependent on the first voltage levelis and the second voltage level in the second system mode.
 10. Thesystem of claim 5 wherein the set of system modes further comprises: afirst system mode wherein one condition is met of the group of: thefirst voltage level is between about 11.5 and about 12.16 volts and thesecond voltage level is between about 11.86 and about 12.16 volts; and,the first voltage level is between about 11.86 and about 12.16 volts andthe second voltage level is between about 11.5 and about 11.86 volts. asecond system mode wherein one condition is met of the group of: thefirst voltage level is between about 11.5 and about 12.16 volts and thesecond voltage level is between about 11.86 and about 12.16 volts; and,the first voltage level is between about 11.86 and about 12.16 volts andthe second voltage level is between about 11.5 and about 11.86 volts;and, a third system mode wherein the first voltage level is betweenabout 11.5 and about 11.86 volts and the second voltage level is betweenabout 11.5 and about 11.86 volts.
 11. The system of claim 10 wherein theprocessor is further configured to: set the first switch and the secondswitch to alternate a supply power to the load from the first batteryand the second battery in the first system mode; and, set the firstswitch and the second switch to supply power to the load from either thefirst battery or the second battery dependent on the first voltage levelis and the second voltage level is in the second system mode. set thefirst switch and the second switch to supply power to the load from boththe first battery and the second battery in the third system mode. 12.The system of claim 10 further comprising: a fourth system mode wherein:the first voltage level is between about 11.5 and about 16 volts and thesecond voltage level is between about 0 and about 11.5 volts or aboveabout 16 volts; a fifth system mode wherein: the first voltage level isbetween about 0 and about 11.5 volts or above about 16 volts and thesecond voltage level is between about 11.5 and about 16 volts; and, asixth system mode wherein: the first voltage level is between about 0and about 11.5 volts or above about 16 volts and the second voltagelevel is between about 0 and about 11.5 volts or above about 16 volts.13. The system of claim 12 wherein the processor is further configuredto: set the first switch and the second switch to supply power from thefirst battery in the fourth system mode; and, set the first switch andthe second switch to supply power from the second battery in the fifthsystem mode.
 14. The system of claim 4 wherein the microprocessor isfurther configured to: set visual indicator according to a system modeof the set of system modes.
 15. The system of claim 4 further comprisinga communications circuit connected to the microprocessor and themicroprocessor is further configured to send a message from thecommunications circuit based on a system mode of the set of systemmodes.
 16. A method for balancing power supplied to a load from a firstbattery and a second battery comprising: periodically measuring a firstvoltage level from the first battery; periodically measuring a secondvoltage level from the second battery; determining a system mode bycomparing the first voltage level and the second voltage to a voltagelook-up table; setting a first switch connected between the firstbattery and the load, according to the system mode; setting a secondswitch connected between the battery and the load, according to thesystem mode; entering a sleep mode for a predetermined period time; and,generating an interrupt that cancels sleep mode upon an overvoltcondition at one or more of the first battery and the second battery.17. The method of claim 16 wherein the step of determining furthercomprises: determining one of the group of: a first system mode whereinone condition is met of the group of: the first voltage range is one ofthe group of V0, V25, V50, V75, V100 and VCHARGING and the secondvoltage range is one of the group of V75, V100 and VCHARGING; and, thefirst voltage range is V75, V100 or VCHARGING and the second voltagerange is one of the group of V0, V25, and V50; a second system modewherein the first voltage range is V0, V25, or V50 and the secondvoltage range is one of the group of V0, V25, and V50; where: VO isbetween about 0.0 and about 2.0 volts; V25 is between about 11.5 andabout 11.62 volts; V50 is between about 11.86 and about 12.16 volts; V75is between about 12.16 and 12.49 volts; V100 is between about 12.49 and12.75 volts; and VCHARGING is between about 17.75 and about 16.0 volts.18. The method of claim 16 wherein the step of determining furthercomprises: determining one of the group of: a first system mode whereinone condition is met of the group of: the first voltage range is one ofthe group of V0, V25, V50, V75, V100 and VCHARGING and the secondvoltage range is one of the group of V75, V100 and VCHARGING; and, thefirst voltage range is one of the group of V75, V100 or VCHARGING andthe second voltage range is V0, V25, and V50; a second system modewherein one condition is met of the group of: the first voltage range isone of the group of V0, V25, V50, V75, V100 and VCHARGING and the secondvoltage range V75, V100 or VCHARGING; the first voltage range is one ofthe group of V75, V100 and VCHARGING and the second voltage range is V0,V25, or V50; and, a third system mode wherein the first voltage range isone of the group of V0 and V25 and the second voltage range is V0 andV25; where: VO is between about 0.0 and about 2.0 volts; V25 is betweenabout 11.5 and about 11.62 volts; V50 is between about 11.86 and about12.16 volts; V75 is between about 12.16 and 12.49 volts; V100 is betweenabout 12.49 and 12.75 volts; and VCHARGING is between about 17.75 andabout 16.0 volts.
 19. The method of claim 18 further comprising thesteps of: setting the first switch and the second switch in analternating pattern in the first system mode; setting the first switchand the second switch according to the first voltage level and thesecond voltage level in the second system mode; and, setting the firstswitch and the second switch to both supply power to the load in thethird system mode.
 20. The method of claim 16 further comprising thesteps of: setting the first switch and the second switch in analternating pattern when in the first system mode; and, setting thefirst switch and the second switch according to the first voltage leveland the second voltage level in the second system mode.
 21. The methodof claim 16 further comprising the step of: activating an indicatoraccording to the system mode.
 22. The method of claim 16 furthercomprising the step of: sending a wireless signal according to thesystem mode.